// <copyright file="ExtensionMethods.cs" company="Alan Dean">
// The MIT License

// Copyright (c) 2008 Alan Dean

// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:

// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.

// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
// </copyright>
// <author>Alan Dean</author>
// <email>alan.dean@thoughtpad.net</email>

namespace Semantic.Rdf.DublinCore
{
    using System;
    using System.Diagnostics.CodeAnalysis;
    using System.Globalization;
    using System.Net.Mime;

    /// <summary>
    /// Represents Dublin Core extension methods.
    /// <para>This class cannot be inherited.</para>
    /// </summary>
    public static class ExtensionMethods
    {
        #region public static Contributor DublinCoreContributor(this Triple, object)
        /// <summary>
        /// Creates an <see cref="T:Semantic.Rdf.DublinCore.Contributor">dc:contributor</see> with the same subject
        /// as this <paramref name="triple"/> and the specified <paramref name="obj">object</paramref>.
        /// </summary>
        /// 
        /// <param name="triple">The triple to be extended.</param>
        /// <param name="obj">The dc:contributor object.</param>
        /// 
        /// <returns>
        /// An <see cref="T:Semantic.Rdf.DublinCore.Contributor">dc:contributor</see> with the same subject as this instance.
        /// </returns>
        /// 
        /// <exception cref="T:System.ArgumentNullException">
        /// <paramref name="triple"/> is a <see langword="null"/> reference.<br/>-or-<br/>
        /// <paramref name="obj"/> is a <see langword="null"/> reference.
        /// </exception>
        [SuppressMessage("Microsoft.Naming", "CA1720:IdentifiersShouldNotContainTypeNames", MessageId = "obj", Justification = "This is the appropriate naming.")]
        public static Contributor DublinCoreContributor(this Triple triple, object obj)
        {
            if (null == triple)
            {
                throw new ArgumentNullException("triple");
            }

            return new Contributor(triple.Subject, obj);
        }
        #endregion

        #region public static Coverage DublinCoreCoverage(this Triple, object)
        /// <summary>
        /// Creates an <see cref="T:Semantic.Rdf.DublinCore.Coverage">dc:coverage</see> with the same subject
        /// as this <paramref name="triple"/> and the specified <paramref name="obj">object</paramref>.
        /// </summary>
        /// 
        /// <param name="triple">The triple to be extended.</param>
        /// <param name="obj">The dc:coverage object.</param>
        /// 
        /// <returns>
        /// An <see cref="T:Semantic.Rdf.DublinCore.Coverage">dc:coverage</see> with the same subject as this instance.
        /// </returns>
        /// 
        /// <exception cref="T:System.ArgumentNullException">
        /// <paramref name="triple"/> is a <see langword="null"/> reference.<br/>-or-<br/>
        /// <paramref name="obj"/> is a <see langword="null"/> reference.
        /// </exception>
        [SuppressMessage("Microsoft.Naming", "CA1720:IdentifiersShouldNotContainTypeNames", MessageId = "obj", Justification = "This is the appropriate naming.")]
        public static Coverage DublinCoreCoverage(this Triple triple, object obj)
        {
            if (null == triple)
            {
                throw new ArgumentNullException("triple");
            }

            return new Coverage(triple.Subject, obj);
        }
        #endregion

        #region public static Creator DublinCoreCreator(this Triple, object)
        /// <summary>
        /// Creates an <see cref="T:Semantic.Rdf.DublinCore.Creator">dc:creator</see> with the same subject
        /// as this <paramref name="triple"/> and the specified <paramref name="obj">object</paramref>.
        /// </summary>
        /// 
        /// <param name="triple">The triple to be extended.</param>
        /// <param name="obj">The dc:creator object.</param>
        /// 
        /// <returns>
        /// An <see cref="T:Semantic.Rdf.DublinCore.Creator">dc:creator</see> with the same subject as this instance.
        /// </returns>
        /// 
        /// <exception cref="T:System.ArgumentNullException">
        /// <paramref name="triple"/> is a <see langword="null"/> reference.<br/>-or-<br/>
        /// <paramref name="obj"/> is a <see langword="null"/> reference.
        /// </exception>
        [SuppressMessage("Microsoft.Naming", "CA1720:IdentifiersShouldNotContainTypeNames", MessageId = "obj", Justification = "This is the appropriate naming.")]
        public static Creator DublinCoreCreator(this Triple triple, object obj)
        {
            if (null == triple)
            {
                throw new ArgumentNullException("triple");
            }

            return new Creator(triple.Subject, obj);
        }
        #endregion

        #region public static Date DublinCoreDate(this Triple, DateTime)
        /// <summary>
        /// Creates an <see cref="T:Semantic.Rdf.DublinCore.Date">dc:date</see> with the same subject
        /// as this <paramref name="triple"/> and the specified <paramref name="obj">object</paramref>.
        /// </summary>
        /// 
        /// <param name="triple">The triple to be extended.</param>
        /// <param name="obj">The dc:date object.</param>
        /// 
        /// <returns>
        /// An <see cref="T:Semantic.Rdf.DublinCore.Date">dc:date</see> with the same subject as this instance.
        /// </returns>
        /// 
        /// <exception cref="T:System.ArgumentNullException">
        /// <paramref name="triple"/> is a <see langword="null"/> reference.<br/>-or-<br/>
        /// <paramref name="obj"/> is a <see langword="null"/> reference.
        /// </exception>
        [SuppressMessage("Microsoft.Naming", "CA1720:IdentifiersShouldNotContainTypeNames", MessageId = "obj", Justification = "This is the appropriate naming.")]
        public static Date DublinCoreDate(this Triple triple, DateTime obj)
        {
            if (null == triple)
            {
                throw new ArgumentNullException("triple");
            }

            return new Date(triple.Subject, obj);
        }
        #endregion

        #region public static Date DublinCoreDate(this Triple, string)
        /// <summary>
        /// Creates an <see cref="T:Semantic.Rdf.DublinCore.Date">dc:date</see> with the same subject
        /// as this <paramref name="triple"/> and the specified <paramref name="obj">object</paramref>.
        /// </summary>
        /// 
        /// <param name="triple">The triple to be extended.</param>
        /// <param name="obj">The dc:date object.</param>
        /// 
        /// <returns>
        /// An <see cref="T:Semantic.Rdf.DublinCore.Date">dc:date</see> with the same subject as this instance.
        /// </returns>
        /// 
        /// <exception cref="T:System.ArgumentNullException">
        /// <paramref name="triple"/> is a <see langword="null"/> reference.<br/>-or-<br/>
        /// <paramref name="obj"/> is a <see langword="null"/> reference.
        /// </exception>
        [SuppressMessage("Microsoft.Naming", "CA1720:IdentifiersShouldNotContainTypeNames", MessageId = "obj", Justification = "This is the appropriate naming.")]
        public static Date DublinCoreDate(this Triple triple, string obj)
        {
            if (null == triple)
            {
                throw new ArgumentNullException("triple");
            }

            return new Date(triple.Subject, obj);
        }
        #endregion

        #region public static Description DublinCoreDescription(this Triple, object)
        /// <summary>
        /// Creates an <see cref="T:Semantic.Rdf.DublinCore.Description">dc:description</see> with the same subject
        /// as this <paramref name="triple"/> and the specified <paramref name="obj">object</paramref>.
        /// </summary>
        /// 
        /// <param name="triple">The triple to be extended.</param>
        /// <param name="obj">The dc:description object.</param>
        /// 
        /// <returns>
        /// An <see cref="T:Semantic.Rdf.DublinCore.Description">dc:description</see> with the same subject as this instance.
        /// </returns>
        /// 
        /// <exception cref="T:System.ArgumentNullException">
        /// <paramref name="triple"/> is a <see langword="null"/> reference.<br/>-or-<br/>
        /// <paramref name="obj"/> is a <see langword="null"/> reference.
        /// </exception>
        [SuppressMessage("Microsoft.Naming", "CA1720:IdentifiersShouldNotContainTypeNames", MessageId = "obj", Justification = "This is the appropriate naming.")]
        public static Description DublinCoreDescription(this Triple triple, object obj)
        {
            if (null == triple)
            {
                throw new ArgumentNullException("triple");
            }

            return new Description(triple.Subject, obj);
        }
        #endregion

        #region public static Format DublinCoreFormat(this Triple, ContentType)
        /// <summary>
        /// Creates an <see cref="T:Semantic.Rdf.DublinCore.Format">dc:format</see> with the same subject
        /// as this <paramref name="triple"/> and the specified <paramref name="obj">object</paramref>.
        /// </summary>
        /// 
        /// <param name="triple">The triple to be extended.</param>
        /// <param name="obj">The dc:format object.</param>
        /// 
        /// <returns>
        /// An <see cref="T:Semantic.Rdf.DublinCore.Format">dc:format</see> with the same subject as this instance.
        /// </returns>
        /// 
        /// <exception cref="T:System.ArgumentNullException">
        /// <paramref name="triple"/> is a <see langword="null"/> reference.<br/>-or-<br/>
        /// <paramref name="obj"/> is a <see langword="null"/> reference.
        /// </exception>
        [SuppressMessage("Microsoft.Naming", "CA1720:IdentifiersShouldNotContainTypeNames", MessageId = "obj", Justification = "This is the appropriate naming.")]
        public static Format DublinCoreFormat(this Triple triple, ContentType obj)
        {
            if (null == triple)
            {
                throw new ArgumentNullException("triple");
            }

            return new Format(triple.Subject, obj);
        }
        #endregion

        #region public static Format DublinCoreFormat(this Triple, string)
        /// <summary>
        /// Creates an <see cref="T:Semantic.Rdf.DublinCore.Format">dc:format</see> with the same subject
        /// as this <paramref name="triple"/> and the specified <paramref name="obj">object</paramref>.
        /// </summary>
        /// 
        /// <param name="triple">The triple to be extended.</param>
        /// <param name="obj">The dc:format object.</param>
        /// 
        /// <returns>
        /// An <see cref="T:Semantic.Rdf.DublinCore.Format">dc:format</see> with the same subject as this instance.
        /// </returns>
        /// 
        /// <exception cref="T:System.ArgumentNullException">
        /// <paramref name="triple"/> is a <see langword="null"/> reference.<br/>-or-<br/>
        /// <paramref name="obj"/> is a <see langword="null"/> reference.
        /// </exception>
        [SuppressMessage("Microsoft.Naming", "CA1720:IdentifiersShouldNotContainTypeNames", MessageId = "obj", Justification = "This is the appropriate naming.")]
        public static Format DublinCoreFormat(this Triple triple, string obj)
        {
            if (null == triple)
            {
                throw new ArgumentNullException("triple");
            }

            return new Format(triple.Subject, obj);
        }
        #endregion

        #region public static Identifier DublinCoreIdentifier(this Triple, Uri)
        /// <summary>
        /// Creates an <see cref="T:Semantic.Rdf.DublinCore.Identifier">dc:identifier</see> with the same subject
        /// as this <paramref name="triple"/> and the specified <paramref name="obj">object</paramref>.
        /// </summary>
        /// 
        /// <param name="triple">The triple to be extended.</param>
        /// <param name="obj">The dc:identifier object.</param>
        /// 
        /// <returns>
        /// An <see cref="T:Semantic.Rdf.DublinCore.Identifier">dc:identifier</see> with the same subject as this instance.
        /// </returns>
        /// 
        /// <exception cref="T:System.ArgumentNullException">
        /// <paramref name="triple"/> is a <see langword="null"/> reference.<br/>-or-<br/>
        /// <paramref name="obj"/> is a <see langword="null"/> reference.
        /// </exception>
        [SuppressMessage("Microsoft.Naming", "CA1720:IdentifiersShouldNotContainTypeNames", MessageId = "obj", Justification = "This is the appropriate naming.")]
        public static Identifier DublinCoreIdentifier(this Triple triple, Uri obj)
        {
            if (null == triple)
            {
                throw new ArgumentNullException("triple");
            }

            return new Identifier(triple.Subject, obj);
        }
        #endregion

        #region public static Identifier DublinCoreIdentifier(this Triple, string)
        /// <summary>
        /// Creates an <see cref="T:Semantic.Rdf.DublinCore.Identifier">dc:identifier</see> with the same subject
        /// as this <paramref name="triple"/> and the specified <paramref name="obj">object</paramref>.
        /// </summary>
        /// 
        /// <param name="triple">The triple to be extended.</param>
        /// <param name="obj">The dc:identifier object.</param>
        /// 
        /// <returns>
        /// An <see cref="T:Semantic.Rdf.DublinCore.Identifier">dc:identifier</see> with the same subject as this instance.
        /// </returns>
        /// 
        /// <exception cref="T:System.ArgumentNullException">
        /// <paramref name="triple"/> is a <see langword="null"/> reference.<br/>-or-<br/>
        /// <paramref name="obj"/> is a <see langword="null"/> reference.
        /// </exception>
        [SuppressMessage("Microsoft.Design", "CA1057:StringUriOverloadsCallSystemUriOverloads", Justification = "This design is intentional.")]
        [SuppressMessage("Microsoft.Naming", "CA1720:IdentifiersShouldNotContainTypeNames", MessageId = "obj", Justification = "This is the appropriate naming.")]
        public static Identifier DublinCoreIdentifier(this Triple triple, string obj)
        {
            if (null == triple)
            {
                throw new ArgumentNullException("triple");
            }

            return new Identifier(triple.Subject, obj);
        }
        #endregion

        #region public static Language DublinCoreLanguage(this Triple, CultureInfo)
        /// <summary>
        /// Creates an <see cref="T:Semantic.Rdf.DublinCore.Language">dc:language</see> with the same subject
        /// as this <paramref name="triple"/> and the specified <paramref name="obj">object</paramref>.
        /// </summary>
        /// 
        /// <param name="triple">The triple to be extended.</param>
        /// <param name="obj">The dc:language object.</param>
        /// 
        /// <returns>
        /// An <see cref="T:Semantic.Rdf.DublinCore.Language">dc:language</see> with the same subject as this instance.
        /// </returns>
        /// 
        /// <exception cref="T:System.ArgumentNullException">
        /// <paramref name="triple"/> is a <see langword="null"/> reference.<br/>-or-<br/>
        /// <paramref name="obj"/> is a <see langword="null"/> reference.
        /// </exception>
        [SuppressMessage("Microsoft.Naming", "CA1720:IdentifiersShouldNotContainTypeNames", MessageId = "obj", Justification = "This is the appropriate naming.")]
        public static Language DublinCoreLanguage(this Triple triple, CultureInfo obj)
        {
            if (null == triple)
            {
                throw new ArgumentNullException("triple");
            }
            
            return new Language(triple.Subject, obj);
        }
        #endregion

        #region public static Language DublinCoreLanguage(this Triple, string)
        /// <summary>
        /// Creates an <see cref="T:Semantic.Rdf.DublinCore.Language">dc:language</see> with the same subject
        /// as this <paramref name="triple"/> and the specified <paramref name="obj">object</paramref>.
        /// </summary>
        /// 
        /// <param name="triple">The triple to be extended.</param>
        /// <param name="obj">The dc:language object.</param>
        /// 
        /// <returns>
        /// An <see cref="T:Semantic.Rdf.DublinCore.Language">dc:language</see> with the same subject as this instance.
        /// </returns>
        /// 
        /// <exception cref="T:System.ArgumentNullException">
        /// <paramref name="triple"/> is a <see langword="null"/> reference.<br/>-or-<br/>
        /// <paramref name="obj"/> is a <see langword="null"/> reference.
        /// </exception>
        [SuppressMessage("Microsoft.Naming", "CA1720:IdentifiersShouldNotContainTypeNames", MessageId = "obj", Justification = "This is the appropriate naming.")]
        public static Language DublinCoreLanguage(this Triple triple, string obj)
        {
            if (null == triple)
            {
                throw new ArgumentNullException("triple");
            }

            return new Language(triple.Subject, obj);
        }
        #endregion

        #region public static Publisher DublinCorePublisher(this Triple, object)
        /// <summary>
        /// Creates an <see cref="T:Semantic.Rdf.DublinCore.Publisher">dc:publisher</see> with the same subject
        /// as this <paramref name="triple"/> and the specified <paramref name="obj">object</paramref>.
        /// </summary>
        /// 
        /// <param name="triple">The triple to be extended.</param>
        /// <param name="obj">The dc:publisher object.</param>
        /// 
        /// <returns>
        /// An <see cref="T:Semantic.Rdf.DublinCore.Publisher">dc:publisher</see> with the same subject as this instance.
        /// </returns>
        /// 
        /// <exception cref="T:System.ArgumentNullException">
        /// <paramref name="triple"/> is a <see langword="null"/> reference.<br/>-or-<br/>
        /// <paramref name="obj"/> is a <see langword="null"/> reference.
        /// </exception>
        [SuppressMessage("Microsoft.Naming", "CA1720:IdentifiersShouldNotContainTypeNames", MessageId = "obj", Justification = "This is the appropriate naming.")]
        public static Publisher DublinCorePublisher(this Triple triple, object obj)
        {
            if (null == triple)
            {
                throw new ArgumentNullException("triple");
            }

            return new Publisher(triple.Subject, obj);
        }
        #endregion

        #region public static Relation DublinCoreRelation(this Triple, object)
        /// <summary>
        /// Creates an <see cref="T:Semantic.Rdf.DublinCore.Relation">dc:relation</see> with the same subject
        /// as this <paramref name="triple"/> and the specified <paramref name="obj">object</paramref>.
        /// </summary>
        /// 
        /// <param name="triple">The triple to be extended.</param>
        /// <param name="obj">The dc:relation object.</param>
        /// 
        /// <returns>
        /// An <see cref="T:Semantic.Rdf.DublinCore.Relation">dc:relation</see> with the same subject as this instance.
        /// </returns>
        /// 
        /// <exception cref="T:System.ArgumentNullException">
        /// <paramref name="triple"/> is a <see langword="null"/> reference.<br/>-or-<br/>
        /// <paramref name="obj"/> is a <see langword="null"/> reference.
        /// </exception>
        [SuppressMessage("Microsoft.Naming", "CA1720:IdentifiersShouldNotContainTypeNames", MessageId = "obj", Justification = "This is the appropriate naming.")]
        public static Relation DublinCoreRelation(this Triple triple, object obj)
        {
            if (null == triple)
            {
                throw new ArgumentNullException("triple");
            }

            return new Relation(triple.Subject, obj);
        }
        #endregion

        #region public static Rights DublinCoreRights(this Triple, object)
        /// <summary>
        /// Creates an <see cref="T:Semantic.Rdf.DublinCore.Rights">dc:rights</see> with the same subject
        /// as this <paramref name="triple"/> and the specified <paramref name="obj">object</paramref>.
        /// </summary>
        /// 
        /// <param name="triple">The triple to be extended.</param>
        /// <param name="obj">The dc:rights object.</param>
        /// 
        /// <returns>
        /// An <see cref="T:Semantic.Rdf.DublinCore.Rights">dc:rights</see> with the same subject as this instance.
        /// </returns>
        /// 
        /// <exception cref="T:System.ArgumentNullException">
        /// <paramref name="triple"/> is a <see langword="null"/> reference.<br/>-or-<br/>
        /// <paramref name="obj"/> is a <see langword="null"/> reference.
        /// </exception>
        [SuppressMessage("Microsoft.Naming", "CA1720:IdentifiersShouldNotContainTypeNames", MessageId = "obj", Justification = "This is the appropriate naming.")]
        public static Rights DublinCoreRights(this Triple triple, object obj)
        {
            if (null == triple)
            {
                throw new ArgumentNullException("triple");
            }

            return new Rights(triple.Subject, obj);
        }
        #endregion

        #region public static Source DublinCoreSource(this Triple, object)
        /// <summary>
        /// Creates an <see cref="T:Semantic.Rdf.DublinCore.Source">dc:source</see> with the same subject
        /// as this <paramref name="triple"/> and the specified <paramref name="obj">object</paramref>.
        /// </summary>
        /// 
        /// <param name="triple">The triple to be extended.</param>
        /// <param name="obj">The dc:source object.</param>
        /// 
        /// <returns>
        /// An <see cref="T:Semantic.Rdf.DublinCore.Source">dc:source</see> with the same subject as this instance.
        /// </returns>
        /// 
        /// <exception cref="T:System.ArgumentNullException">
        /// <paramref name="triple"/> is a <see langword="null"/> reference.<br/>-or-<br/>
        /// <paramref name="obj"/> is a <see langword="null"/> reference.
        /// </exception>
        [SuppressMessage("Microsoft.Naming", "CA1720:IdentifiersShouldNotContainTypeNames", MessageId = "obj", Justification = "This is the appropriate naming.")]
        public static Source DublinCoreSource(this Triple triple, object obj)
        {
            if (null == triple)
            {
                throw new ArgumentNullException("triple");
            }

            return new Source(triple.Subject, obj);
        }
        #endregion

        #region public static Title DublinCoreTitle(this Triple, object)
        /// <summary>
        /// Creates an <see cref="T:Semantic.Rdf.DublinCore.Title">dc:title</see> with the same subject
        /// as this <paramref name="triple"/> and the specified <paramref name="obj">object</paramref>.
        /// </summary>
        /// 
        /// <param name="triple">The triple to be extended.</param>
        /// <param name="obj">The dc:title object.</param>
        /// 
        /// <returns>
        /// An <see cref="T:Semantic.Rdf.DublinCore.Title">dc:title</see> with the same subject as this instance.
        /// </returns>
        /// 
        /// <exception cref="T:System.ArgumentNullException">
        /// <paramref name="triple"/> is a <see langword="null"/> reference.<br/>-or-<br/>
        /// <paramref name="obj"/> is a <see langword="null"/> reference.
        /// </exception>
        [SuppressMessage("Microsoft.Naming", "CA1720:IdentifiersShouldNotContainTypeNames", MessageId = "obj", Justification = "This is the appropriate naming.")]
        public static Title DublinCoreTitle(this Triple triple, object obj)
        {
            if (null == triple)
            {
                throw new ArgumentNullException("triple");
            }

            return new Title(triple.Subject, obj);
        }
        #endregion

        #region public static Type DublinCoreType(this Triple, object)
        /// <summary>
        /// Creates an <see cref="T:Semantic.Rdf.DublinCore.Type">dc:type</see> with the same subject
        /// as this <paramref name="triple"/> and the specified <paramref name="obj">object</paramref>.
        /// </summary>
        /// 
        /// <param name="triple">The triple to be extended.</param>
        /// <param name="obj">The dc:type object.</param>
        /// 
        /// <returns>
        /// An <see cref="T:Semantic.Rdf.DublinCore.Type">dc:type</see> with the same subject as this instance.
        /// </returns>
        /// 
        /// <exception cref="T:System.ArgumentNullException">
        /// <paramref name="triple"/> is a <see langword="null"/> reference.<br/>-or-<br/>
        /// <paramref name="obj"/> is a <see langword="null"/> reference.
        /// </exception>
        [SuppressMessage("Microsoft.Naming", "CA1720:IdentifiersShouldNotContainTypeNames", MessageId = "obj", Justification = "This is the appropriate naming.")]
        public static Type DublinCoreType(this Triple triple, object obj)
        {
            if (null == triple)
            {
                throw new ArgumentNullException("triple");
            }

            return new Type(triple.Subject, obj);
        }
        #endregion
    }
}